#ifndef _BUOLA_NET_CHTTPFORM_H_
#define _BUOLA_NET_CHTTPFORM_H_

namespace buola { namespace io {

template<typename tForm>
class CHTTPFormAssigner
{
    CHTTPFormAssigner(const std::string &pName,tForm *pForm)
        :   mName(pName)
        ,   mForm(pForm)
    {

    }

public:
    void operator=(const std::string &pValue)
    {
        mForm->Add(mName,pValue);
    }

private:
    const std::string &mName;
    tForm *mForm;

    friend class CHTTPForm;
    friend class CHTTPMultiForm;
};

class CHTTPForm
{
public:
    CHTTPForm();

    CHTTPFormAssigner<CHTTPForm> operator[](const std::string &pName)
    {
        return CHTTPFormAssigner<CHTTPForm>(pName,this);
    }


    void Add(const std::string &pName,const std::string &pValue);

    const std::string &GetText() const   {   return mText;   }

private:
    std::string mText;
};

class CHTTPMultiForm
{
    class SPImpl;

public:
    CHTTPMultiForm();
    ~CHTTPMultiForm();

    CHTTPFormAssigner<CHTTPMultiForm> operator[](const std::string &pName)
    {
        return CHTTPFormAssigner<CHTTPMultiForm>(pName,this);
    }

    void Add(const std::string &pName,const std::string &pValue);

private:
    std::unique_ptr<SPImpl> mPImpl;
};

/*namespace io*/ } /*namespace buola*/ }

#endif
